﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;

namespace WebSys.UI.Control.ZhengShou
{
    public class ZS_FXPGXMControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        CustomGridView CustomGridList1;
        TextBox xmmc, lxh;
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            CustomGridList1 = (CustomGridView)FindControl("CustomGridList1");
            xmmc = (TextBox)FindControl("txtProName");
            lxh = (TextBox)FindControl("txtProNo");
            if (!base.Page.IsPostBack)
            {
                Bind();
            }
            Button btnsearch = (Button)FindControl("btnSeach");
            btnsearch.Click += new EventHandler(btnsearch_Click);
            CustomGridList1.OnLoadData += new EventHandler(CustomGridList1_OnLoadData);
        }

        protected void btnsearch_Click(object sender, EventArgs e)
        {
            Bind();
        }

        protected void Bind()
        {
            string sql = "select * from zs_project where 1=1 ";
            string strWhere = string.Empty;
            if (!string.IsNullOrEmpty(xmmc.Text.Trim()))
            {
                strWhere += " and 项目名称  like '%" + xmmc.Text + "%'";
            }
            if (!string.IsNullOrEmpty(lxh.Text.Trim()))
            {
                strWhere += " and 立项号 like '%" + lxh.Text + "%'";
            }
            sql += strWhere;
            sql += " order by addtime desc";
            DataTable dt = _EluZSDataProvider.GetTable(sql);
            CustomGridList1.DataSource = dt;
            CustomGridList1.RecordCount = dt.Rows.Count;
            CustomGridList1.PageSize = 10;
            CustomGridList1.DataKeyNames = new string[] { "ID" };
            CustomGridList1.DataBind();
           
        }
        protected void CustomGridList1_OnLoadData(object sender, EventArgs e)
        {
            Bind();
        }
    }
}


